/*
 * @Author: your name
 * @Date: 2021-10-20 21:28:11
 * @LastEditTime: 2021-10-21 20:19:40
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \luogu\动态规划\模板问题\P1020 导弹拦截\main.cpp
 */
#include<iostream>
#include<algorithm>
using namespace std;

//导弹高度
int h[100010];
//f[i] 前i个导弹的最大拦截数目 最长下降子序列
int f[100010];
//g[j] 最长上升子序列
int g[100010];

int main(){
    int n;
    cin >> n;
    //记录最长下降子序列数目
    int maxf = 0;
    int maxg = 0;
    for(int i=1; i<=n; i++){
        cin >> h[i];
        //最少击落一个
        f[i] = 1;
        g[i] = 1;
        //动态规划
        for(int j=1; j<i; j++){
            if(h[i] <= h[j]){
                f[i] = max(f[i],f[j]+1);
            }
            if(h[i] > h[j]){
                g[i] = max(g[i],g[j]+1);
            }
        }
        maxf = f[i] > maxf ? f[i] : maxf;
        maxg = g[i] > maxg ? g[i] : maxg;
    }
    cout << maxf << endl;
    cout << maxg << endl;
    // cout << "---------------------" << endl;
    // for(int i=1; i<=n; i++){
    //     cout << "index:" << i
    //         << " h:" << h[i] 
    //         << " g(up):" << g[i]
    //         << " f(down):" << f[i] << endl;
    // }
    return 0;
}
